package com.study.mapper;

import com.study.entity.Dept;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DeptMapper {

    List<Dept> depts();

    @Delete("DELETE FROM dept WHERE id = #{id}") //mybatis中#{}是使用预编译，可防止SQL注入，安全、性能好，而${}是拼接，不能防止SQL注入
    void delete(Integer id);

    @Insert("INSERT INTO dept(name,create_time,update_time) VALUES(#{name},#{createTime},#{updateTime})")
    void add(Dept dept);

    @Select("SELECT * FROM dept WHERE id = #{id}")
    Dept selectById(Integer id);

   // @Update("UPDATE dept SET name = #{name},update_time=#{updateTime} WHERE id = #{id}")
    void update(Dept dept);
}
